const { DataTypes } = require('sequelize')
const sequelize = require('./db')

const UserToken = sequelize.define(
  'UserToken',
  {
    username: {
      type: DataTypes.STRING,
      allowNull: false,
      comment: '用户id',
    },
    userType: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: '用户类型',
    },
    token: {
      type: DataTypes.STRING(1234),
      allowNull: false,
      comment: '用户token',
    },
    expireTime: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: 'token过期时间',
    },
    updateTime: {
      type: DataTypes.DATE,
      allowNull: false,
      defaultValue: DataTypes.NOW,
      comment: '更新时间',
    },
  },
  {
    tableName: 'UserToken',
    timestamps: false,
    comment: '用户token表',
  }
)

module.exports = UserToken
